import { filterAndMap } from './filter-and-map'

const isNum = value => !isNaN(Number(value)) // do not change to typeof value === 'number'
const isStr = value => typeof value === 'string'

export const enumToNames = (e): string[] => {
  return Object.keys(e).filter(isStr)
}

export const enumToValues = (e) => {
  return filterAndMap<string | number, number>(
    Object.keys(e),
    isNum,
    (v) => Number(v),
  )
}